package com.sdry.project.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sdry.common.BaseController;
import com.sdry.common.TableDataInfo;
import com.sdry.project.entity.ProjectEntity;
import com.sdry.project.entity.ProjectExpertEntity;
import com.sdry.project.service.ProjectExpertService;
import com.sdry.system.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.List;

/**
 * @Description
 * @Author chenBin
 * @Date 2020-08-20 16:45
 * @Version 1.0
 **/
@Controller
@RequestMapping(value = "unReview")
public class UnReviewController extends BaseController {

    @Autowired
    private ProjectExpertService projectExpertService;

    @RequestMapping(value = "show")
    public String show() {
        return "project/project/project";
    }

    /**
     * 根据登录用户（专家）查询所关联的项目
     * @param projectExpertEntity 查询实体
     */
    @RequestMapping(value = "/selectProjectByUser")
    @ResponseBody
    public TableDataInfo selectProjectByUser(ProjectExpertEntity projectExpertEntity, HttpServletRequest httpServletRequest) {
        SysUser sysUser = (SysUser)httpServletRequest.getSession().getAttribute("user");
        projectExpertEntity.setUserId(sysUser.getUserId());
        List<ProjectExpertEntity> list = projectExpertService.listByUidNotExpert(projectExpertEntity);
        PageInfo<ProjectExpertEntity> pageInfo = new PageInfo<ProjectExpertEntity>(list);
        return getDataTable(pageInfo.getList(),pageInfo.getTotal());
    }
}
